package com.zoanun.tools.example.json;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("example/json")
public class JsonController {

	private static Logger logger = LoggerFactory.getLogger(JsonController.class);

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> addUserPost(@RequestBody JsonBean model) {
		logger.info("新增");
		logger.info("捕获到前台传递过来的Model，名称为：" + model.getUserName());
		logger.info("捕获到前台传递过来的Model，密码为：" + model.getPassword());

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userName", model.getUserName());
		map.put("success", "true");
		return map;
	}

	@RequestMapping(value = "add", method = RequestMethod.GET)
	public Map<String, Object> addUserGet() {
//		logger.info("新增");
//		logger.info("捕获到前台传递过来的Model，名称为：" + model.getUserName());
//		logger.info("捕获到前台传递过来的Model，密码为：" + model.getPassword());

		Map<String, Object> map = new HashMap<String, Object>(1);
		map.put("success", "true");
		return map;
	}
	
}
